package com.neuedu.jdboot.common;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * 用于适配jquery datatable 服务器分页参数
 * 
 * @author chens
 *
 */
public class DataTableParam implements Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = 5277910777484909463L;
	/**
	 * datatable刷新数据的次数，每次刷新数据该值会累加1
	 */
	private Integer draw;
	/**
	 * 分页的起始数据，从第start条开始查询
	 */
	private Integer start;
	/**
	 * 分页数据的长度，每页显示length条数据
	 */
	private Integer length;
	/**
	 * 搜索框
	 */
	private DataTableSearch search;
	
	/**
	 * 排序与多列搜索
	 */
	private List<DataTableColumn> columns = new ArrayList<DataTableColumn>();

	public Integer getDraw() {
		return draw;
	}

	public void setDraw(Integer draw) {
		this.draw = draw;
	}

	public Integer getStart() {
		return start;
	}

	public void setStart(Integer start) {
		this.start = start;
	}

	public Integer getLength() {
		return length;
	}

	public void setLength(Integer length) {
		this.length = length;
	}

	public DataTableSearch getSearch() {
		return search;
	}

	public void setSearch(DataTableSearch search) {
		this.search = search;
	}

	public List<DataTableColumn> getColumns() {
		return columns;
	}

	public void setColumns(List<DataTableColumn> columns) {
		this.columns = columns;
	}

	public DataTableParam(Integer draw, Integer start, Integer length) {
		super();
		this.draw = draw;
		this.start = start;
		this.length = length;
	}

	public DataTableParam() {
		super();
	}

	@Override
	public String toString() {
		return "DataTableParam [draw=" + draw + ", start=" + start + ", length=" + length + ", search=" + search
				+ ", columns=" + columns + "]";
	}

	public static class DataTableSearch implements Serializable {
		/**
		 * 
		 */
		private static final long serialVersionUID = 1L;
		private String value;
		private Boolean regex;

		public String getValue() {
			return value;
		}

		public void setValue(String value) {
			this.value = value;
		}

		public Boolean getRegex() {
			return regex;
		}

		public void setRegex(Boolean regex) {
			this.regex = regex;
		}

		@Override
		public String toString() {
			return "Search [value=" + value + ", regex=" + regex + "]";
		}

	}

	public static class DataTableColumn implements Serializable {
		/**
		 * 
		 */
		private static final long serialVersionUID = -9112508691942960849L;
		private String data;
		private String name;
		private Boolean searchable;
		private Boolean orderable;
		private DataTableSearch search;

		public String getData() {
			return data;
		}

		public void setData(String data) {
			this.data = data;
		}

		public String getName() {
			return name;
		}

		public void setName(String name) {
			this.name = name;
		}

		public Boolean getSearchable() {
			return searchable;
		}

		public void setSearchable(Boolean searchable) {
			this.searchable = searchable;
		}

		public Boolean getOrderable() {
			return orderable;
		}

		public void setOrderable(Boolean orderable) {
			this.orderable = orderable;
		}

		public DataTableSearch getSearch() {
			return search;
		}

		public void setSearch(DataTableSearch search) {
			this.search = search;
		}

		@Override
		public String toString() {
			return "DataTableColumn [data=" + data + ", name=" + name + ", searchable=" + searchable + ", orderable="
					+ orderable + ", search=" + search + "]";
		}

	}

}
